//========encoding:utf-8=========
/*
 * @describe:  三目运算符
 * @author:mhao
 * @copyright:chinasoft.cn
 * @date:2020年3月16日   下午7:26:11
 */
package edu.chinasoft.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller(value = "userHandler")
public class UserHandler {
	private Logger logger = LoggerFactory.getLogger(UserHandler.class);
	@RequestMapping(value = "/usercontrol.do",method = RequestMethod.POST)
    public void method01(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        logger.info("UserHandler>>>method01 start ……");
        String userName = request.getParameter("user_name");
        String userPasswordr = request.getParameter("user_password");
        logger.info("用户名为："+userName+"；密码为："+userPasswordr+"。");

        /*把数据保存到request容器*/
        request.setAttribute("key01", userName);
        request.setAttribute("key02", userPasswordr);

        //请求转发
        request.getRequestDispatcher("/loginsuccess.jsp").forward(request, response);

        logger.info("UserHandler>>>method01 end ……");
    }
}
